home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performTextureViewGridOption < prev    next >
Encoding:
Text File  |  2003-07-17  |  15.1 KB  |  521 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  September 12, 1997
  22. //
  23. //  Description:
  24. //      This script is use to display and update the grid spacing options.
  25. //
  26. //  Input Arguments:
  27. //      int showOptionBox        true - show the option box dialog
  28. //                                false - just execute the command
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34.  
  35. //
  36. //  Procedure Name:
  37. //      textureWindowPanelName
  38. //
  39. //  Description:
  40. //        return the texture window panel name.
  41. //
  42. //  Input Arguments:
  43. //        
  44. //
  45. //  Return Value:
  46. //      texture window panel name
  47. //
  48. proc string textureWindowPanelName()
  49. {
  50.     string $texWinName[] = `getPanel -sty polyTexturePlacementPanel`;
  51.     return $texWinName[0];
  52. }
  53.  
  54. //
  55. //  Procedure Name:
  56. //      setOptionVars
  57. //
  58. //  Description:
  59. //        Initialize the option values.
  60. //
  61. //  Input Arguments:
  62. //        Whether to set the options to default values.
  63. //
  64. //  Return Value:
  65. //      None.
  66. //
  67. proc setOptionVars(int $forceFactorySettings)
  68. {
  69.     // There don't seem to be any options
  70.  
  71.     // If you wanted these values to be saved between sessions you should
  72.     // put in your optionVars here
  73.  
  74.     //    Grid spacing.
  75.     //
  76.     if ($forceFactorySettings || !`optionVar -exists textureWindowGridSpacing`) {
  77.         optionVar -floatValue textureWindowGridSpacing 0.1;
  78.     }
  79.  
  80.     //    Grid subdivisions.
  81.     //
  82.     if ($forceFactorySettings || !`optionVar -exists textureWindowGridDivisions`) {
  83.         optionVar -floatValue textureWindowGridDivisions 2.0;
  84.     }
  85.  
  86.     //    Grid size.
  87.     //
  88.     if ($forceFactorySettings || !`optionVar -exists textureWindowGridSize`) {
  89.         optionVar -floatValue textureWindowGridSize 1.0;
  90.     }
  91.  
  92.     //    Display grid axes.
  93.     //
  94.     if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridAxes`) {
  95.         optionVar -intValue textureWindowDisplayGridAxes true;
  96.     }
  97.  
  98.     //    Display grid lines.
  99.     //
  100.     if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridLines`) {
  101.         optionVar -intValue textureWindowDisplayGridLines true;
  102.     }
  103.  
  104.     //    Display division lines.
  105.     //
  106.     if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayDivisionLines`) {
  107.         optionVar -intValue textureWindowDisplayDivisionLines false;
  108.     }
  109.  
  110.     //    Display grid labels.
  111.     //
  112.     if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridLabels`) {
  113.         optionVar -intValue textureWindowDisplayGridLabels true;
  114.     }
  115.  
  116.     //    Display location of labels.
  117.     //
  118.     if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridLabelPosition`) {
  119.         optionVar -stringValue textureWindowDisplayGridLabelPosition "axis";
  120.     }
  121. }
  122.  
  123. //
  124. //  Procedure Name:
  125. //      tvGridSetup
  126. //
  127. //  Description:
  128. //        Update the state of the option box UI to reflect the option values.
  129. //
  130. //  Input Arguments:
  131. //      parent               - Top level parent layout of the option box UI.
  132. //                             Required so that UI object names can be 
  133. //                             successfully resolved.
  134. //
  135. //    forceFactorySettings - Whether the option values should be set to
  136. //                             default values.
  137. //
  138. //  Return Value:
  139. //      None.
  140. //
  141. global proc tvGridSetup(string $parent, int $forceFactorySettings)
  142. {
  143.     setParent $parent;
  144.  
  145.     setOptionVars($forceFactorySettings);
  146.  
  147.     //    Get the grid dimension values.
  148.     //
  149.     float  $spacing   = `optionVar -query textureWindowGridSpacing`;
  150.     float  $size      = `optionVar -query textureWindowGridSize`;
  151.     int    $divisions = `optionVar -query textureWindowGridDivisions`;
  152.  
  153.     //    Get the grid display values. 
  154.     //
  155.     int    $displayAxes          = `optionVar -query textureWindowDisplayGridAxes`;
  156.     int    $displayGridLines     = `optionVar -query textureWindowDisplayGridLines`;
  157.     int    $displayDivisionLines = `optionVar -query textureWindowDisplayDivisionLines`;
  158.     int    $displayGridLabels    = `optionVar -query textureWindowDisplayGridLabels`;
  159.     string $labelPosition        = `optionVar -query textureWindowDisplayGridLabelPosition`;
  160.     int    $location;
  161.  
  162.     //    Update the grid controls.
  163.     //
  164.     floatFieldGrp -edit -value1 $size TextureWindowGridOptionsSize;
  165.     floatFieldGrp -edit -value1 $spacing TextureWindowGridOptionsDistance;
  166.     intSliderGrp  -edit -value $divisions TextureWindowGridOptionsDivisions;
  167.  
  168.     //    Update the state of the display controls.
  169.     //
  170.     checkBoxGrp -edit -value1 $displayAxes          TextureWindowGridOptionsDisplayAxes;
  171.     checkBoxGrp -edit -value1 $displayGridLines     TextureWindowGridOptionsDisplayGridLines;
  172.     checkBoxGrp -edit -value1 $displayDivisionLines TextureWindowGridOptionsDisplayDivisionLines;
  173.  
  174.     if ($displayGridLabels) {
  175.         if ("axis" == $labelPosition) {
  176.             $location = 2;
  177.         } else {
  178.             $location = 3;
  179.         }
  180.     } else {
  181.         $location = 1;
  182.     }
  183.     radioButtonGrp -edit -select $location TextureWindowGridOptionsLabelPosition;
  184. }
  185.  
  186. //
  187. //  Procedure Name:
  188. //      tvGridCallback
  189. //
  190. //  Description:
  191. //        Update the option values with the current state of the option box UI.
  192. //
  193. //  Input Arguments:
  194. //      parent - Top level parent layout of the option box UI.  Required so
  195. //               that UI object names can be successfully resolved.
  196. //
  197. //    doIt   - Whether the command should execute.
  198. //
  199. //  Return Value:
  200. //      None.
  201. //
  202. global proc tvGridCallback(string $parent, int $doIt)
  203. {
  204.     //    Get the grid values from the UI.
  205.     //
  206.     float  $size = `floatFieldGrp -query -value1 TextureWindowGridOptionsSize`;
  207.     float  $spacing = `floatFieldGrp -query -value1 TextureWindowGridOptionsDistance`;
  208.     int    $divisions = `intSliderGrp -query -value TextureWindowGridOptionsDivisions`;
  209.  
  210.     //    Get the grid display values.
  211.     //
  212.     int    $displayAxes          = `checkBoxGrp -query -value1 TextureWindowGridOptionsDisplayAxes`;
  213.     int    $displayGridLines     = `checkBoxGrp -query -value1 TextureWindowGridOptionsDisplayGridLines`;
  214.     int    $displayDivisionLines = `checkBoxGrp -query -value1 TextureWindowGridOptionsDisplayDivisionLines`;
  215.     int    $labelPosition        = `radioButtonGrp -query -select TextureWindowGridOptionsLabelPosition`;
  216.  
  217.     //    Verify the values.
  218.     //
  219.     if (1.0 > $size) {
  220.         error ("Length and Width value may not be less than 1.0");
  221.         return;
  222.     }
  223.     if (0.0 >= $spacing) {
  224.         error ("Grid Line spacing must be greater than 0.0");
  225.         return;
  226.     }
  227.  
  228.     //    Update the grid values.
  229.     //
  230.     optionVar -floatValue textureWindowGridSpacing $spacing;
  231.     optionVar -floatValue textureWindowGridSize $size;
  232.     optionVar -floatValue textureWindowGridDivisions $divisions;
  233.  
  234.     //    Update the grid display values.
  235.     //
  236.     optionVar -intValue textureWindowDisplayGridAxes          $displayAxes;
  237.     optionVar -intValue textureWindowDisplayGridLines         $displayGridLines;
  238.     optionVar -intValue textureWindowDisplayDivisionLines     $displayDivisionLines;
  239.  
  240.     if (1 == $labelPosition) {
  241.         optionVar -intValue textureWindowDisplayGridLabels false;
  242.     } else if (2 == $labelPosition) {
  243.         optionVar -stringValue textureWindowDisplayGridLabelPosition "axis";
  244.         optionVar -intValue textureWindowDisplayGridLabels true;
  245.     } else {
  246.         optionVar -stringValue textureWindowDisplayGridLabelPosition "edge";
  247.         optionVar -intValue textureWindowDisplayGridLabels true;
  248.     }
  249.  
  250.     if ($doIt) {
  251.         performTextureViewGridOptions 0; 
  252.         addToRecentCommandQueue "performTextureViewGridOptions 0" "TextureViewGrid";
  253.     }
  254. }
  255.  
  256. //
  257. //  Procedure Name:
  258. //      tvGridOptions
  259. //
  260. //  Description:
  261. //        Construct the option box UI.  Involves accessing the standard option
  262. //        box and customizing the UI accordingly.
  263. //
  264. //  Input Arguments:
  265. //      None.
  266. //
  267. //  Return Value:
  268. //      None.
  269. //
  270. proc tvGridOptions()
  271. {
  272.     //    Name of the command for this option box.
  273.     //
  274.     string $commandName = "tvGrid";
  275.  
  276.     //    Build the option box actions.
  277.     //
  278.     string $callback = ($commandName + "Callback");
  279.     string $setup = ($commandName + "Setup");
  280.  
  281.      //    STEP 1:  Get the option box.
  282.     //    ============================
  283.     //
  284.     //    The value returned is the name of the layout to be used as
  285.     //    the parent for the option box UI.
  286.     //
  287.     string $layout = getOptionBox();
  288.     setParent $layout;
  289.     
  290.     //    STEP 2:  Pass the command name to the option box.
  291.     //    =================================================
  292.     //
  293.     //    Any default option box behaviour based on the command name is set 
  294.     //    up with this call.  For example, updating the 'Help' menu item with
  295.     //    the name of the command.
  296.     //
  297.     setOptionBoxCommandName($commandName);
  298.     
  299.     //    STEP 3:  Activate the default UI template.
  300.     //    ==========================================
  301.     //
  302.     //    Activate the default UI template so that the layout of this 
  303.     //    option box is consistent with the layout of the rest of the 
  304.     //    application.
  305.     //
  306.     setUITemplate -pushTemplate DefaultTemplate;
  307.  
  308.     //    STEP 4: Create option box contents.
  309.     //    ===================================
  310.     //    
  311.     //    This, of course, will vary from option box to option box.    
  312.     
  313.     //    Turn on the wait cursor.
  314.     //
  315.     waitCursor -state 1;
  316.  
  317.     tabLayout -tabsVisible 0 -scrollable 1;
  318.     
  319.     string $parent = `columnLayout -adjustableColumn 1 -rowSpacing 4`;
  320.  
  321.     //    Grid size.
  322.     //
  323.     frameLayout -label "Size" -labelAlign "center" -collapsable false -collapse false;
  324.     columnLayout;
  325.  
  326.     $gridSize = `floatFieldGrp -label "Length and Width"
  327.         -extraLabel "units"
  328.         TextureWindowGridOptionsSize`;
  329.  
  330.     $gridDistance = `floatFieldGrp -label "Grid Lines Every"
  331.         -extraLabel "units"
  332.         TextureWindowGridOptionsDistance`;
  333.  
  334.     $divisions = `intSliderGrp -label "Subdivisions"
  335.         -field true
  336.         -min 2 -max 256 -fieldMinValue 2 -fieldMaxValue 4096 -step 1
  337.         TextureWindowGridOptionsDivisions`;
  338.  
  339.     setParent ..;
  340.     setParent ..;
  341.  
  342.     frameLayout -label "Display" -labelAlign "center" -collapsable false -collapse false;
  343.     columnLayout;
  344.  
  345.     checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 "Axes"
  346.         TextureWindowGridOptionsDisplayAxes;
  347.  
  348.     checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 "Grid Lines"
  349.         TextureWindowGridOptionsDisplayGridLines;
  350.  
  351.     checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 "Subdivision Lines"
  352.         TextureWindowGridOptionsDisplayDivisionLines;
  353.  
  354.     radioButtonGrp -numberOfRadioButtons 3 -label "Grid Numbers"
  355.         -labelArray3 "Hide" "On Axes" "Along Edge"
  356.         TextureWindowGridOptionsLabelPosition;
  357.  
  358.     setParent ..;
  359.     setParent ..;
  360.  
  361.     //    Turn off the wait cursor.
  362.     //
  363.     waitCursor -state 0;
  364.     
  365.     //    Step 5: Deactivate the default UI template.
  366.     //    ===========================================
  367.     //
  368.     setUITemplate -popTemplate;
  369.  
  370.     //    Step 6: Customize the buttons.  
  371.     //    ==============================
  372.     //
  373.     //    Provide more descriptive labels for the buttons.  This is not 
  374.     //    necessary, but in some cases, for example, a button labelled 
  375.     //    'Create' may be more meaningful to the user than one labelled
  376.     //    'Apply'.
  377.     //
  378.     //    Disable those buttons that are not applicable to the option box.
  379.     //
  380.     //    Attach actions to those buttons that are applicable to the option
  381.     //    box.  Note that the 'Close' button has a default action attached 
  382.     //    to it that will hide the window.  If a a custom action is
  383.     //    attached to the 'Close' button then be sure to call the 'hide the
  384.     //    option box' procedure within the custom action so that the option
  385.     //    box is hidden properly.
  386.  
  387.     //    'Apply' button.
  388.     //
  389.     string $applyBtn = getOptionBoxApplyBtn();
  390.     button -edit
  391.         -command ($callback + " " + $parent + " " + 1)
  392.         $applyBtn;
  393.  
  394.     //    'Save' button.
  395.     //
  396.     string $saveBtn = getOptionBoxSaveBtn();
  397.     button -edit 
  398.         -command ($callback + " " + $parent + " " + 1 + "; hideOptionBox")
  399.         $saveBtn;
  400.  
  401.     //    'Reset' button.
  402.     //
  403.     string $resetBtn = getOptionBoxResetBtn();
  404.     button -edit 
  405.         -command ($setup + " " + $parent + " " + 1)
  406.         $resetBtn;
  407.  
  408.     //    Step 7: Set the option box title.
  409.     //    =================================
  410.     //
  411.     setOptionBoxTitle("UV Texture Editor Grid Options");
  412.  
  413.     //    Step 8: Customize the 'Help' menu item text.
  414.     //    ============================================
  415.     //
  416.     setOptionBoxHelpTag( "UVEditorGrid" );
  417.  
  418.     //    Step 9: Set the current values of the option box.
  419.     //    =================================================
  420.     //
  421.     eval (($setup + " " + $parent + " " + 0));    
  422.     
  423.     //    Step 10: Show the option box.
  424.     //    =============================
  425.     //
  426.     showOptionBox();
  427. }
  428.  
  429.  
  430. //
  431. //  Procedure Name:
  432. //      assembleCmd
  433. //
  434. //  Description:
  435. //        Construct the command that will apply the option box values.
  436. //
  437. //  Input Arguments:
  438. //      None.
  439. //
  440. proc string assembleCmd()
  441. {
  442.     string $cmd;
  443.  
  444.     setOptionVars(false);
  445.  
  446.     string $winName = textureWindowPanelName();
  447.  
  448.     float  $spacing   = `optionVar -query textureWindowGridSpacing`;
  449.     int    $divisions = `optionVar -query textureWindowGridDivisions`;
  450.     float  $size      = `optionVar -query textureWindowGridSize`;
  451.  
  452.     int    $displayAxes          = `optionVar -query textureWindowDisplayGridAxes`;
  453.     int    $displayGridLines     = `optionVar -query textureWindowDisplayGridLines`;
  454.     int    $displayDivisionLines = `optionVar -query textureWindowDisplayDivisionLines`;
  455.     int    $displayGridLabels    = `optionVar -query textureWindowDisplayGridLabels`;
  456.     string $labelPosition        = `optionVar -query textureWindowDisplayGridLabelPosition`;
  457.  
  458.     $cmd = "textureWindow -edit -spacing " + $spacing
  459.         + " -divisions " + $divisions
  460.         + " -size " + $size 
  461.         + " -displayAxes " + $displayAxes
  462.         + " -displayGridLines " + $displayGridLines
  463.         + " -displayDivisionLines " + $displayDivisionLines
  464.         + " -displayLabels " + $displayGridLabels
  465.         + " -labelPosition " + $labelPosition
  466.         + " " + $winName + ";"
  467.         ;
  468.     return $cmd;
  469. }
  470.  
  471. //
  472. //  Procedure Name:
  473. //      performTextureViewGridOptions
  474. //
  475. //  Description:
  476. //        Perform the grid command using the corresponding 
  477. //        option values.  This procedure will also show the option box
  478. //        window if necessary as well as construct the command string
  479. //        that will invoke the grid command with the current
  480. //        option box values.
  481. //
  482. //  Input Arguments:
  483. //      0 - Execute the command.
  484. //      1 - Show the option box dialog.
  485. //      2 - Return the command.
  486. //
  487. global proc string performTextureViewGridOptions(int $action)
  488. {
  489.     string $cmd = "";
  490.  
  491.     switch ($action) {
  492.  
  493.         //    Execute the command.
  494.         //
  495.         case 0:
  496.             //    Get the command.
  497.             //
  498.             $cmd = `assembleCmd`;
  499.  
  500.             //    Execute the command with the option settings.
  501.             //
  502.             eval($cmd);
  503.             break;
  504.  
  505.         //    Show the option box.
  506.         //
  507.         case 1:
  508.             tvGridOptions;
  509.             break;
  510.  
  511.         //    Return the command string.
  512.         //
  513.         case 2:
  514.             //    Get the command.
  515.             //
  516.             $cmd = `assembleCmd`;
  517.             break;
  518.     }
  519.     return $cmd;
  520. }
  521.